<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 900px;
            height: auto;
            margin: 0 auto;
            background-color: cadetblue;
            overflow: hidden;
            display: flex;
            justify-content: space-evenly;
            flex-wrap: wrap;
        }

        .ele {
            width: 200px;
            height: 200px;
            display: flex;
            background-color: coral;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="ele"></div>
    </div>
</body>
<script>
    var box = document.querySelector('.box');
    var eles = document.querySelectorAll('.ele');
    // for(var i = 0; i < eles.length ; i++){
    //     eles[i].onclick = function(){
    //         var newele = document.createElement('div');
    //         newele.className = 'ele';
    //         box.appendChild(newele);
    //     }
    // }
    box.onclick = function (event) {
        event = event || window.event;
        console.log(event);
        var target = event.target || event.srcElement;
        if (target.nodeName === 'DIV' && target.className === 'ele') {
            var newele = document.createElement('div');
            newele.className = 'ele';
            box.appendChild(newele);
        }
    }
</script>

</html>